<template>
    <div class="content">
        <div>
            请输入题号: <el-input ref="inputField" :disabled="timeOver" v-model="problem" placeholder="请输入题号" @keyup.enter.native="problemGet"></el-input>
        </div>
        <div style="margin-top: 10px;margin-bottom: 10px;" v-show="!showInputNumber">
            -
        </div>
        <div style="margin-top: 10px;margin-bottom: 10px;" v-show="showInputNumber">
            <span style="font-size: 20px;">请输入第  {{ pageRandom }}  到第  {{ pageRandom+18 }} 页中的第  {{ rowRandom }} 行数字</span>
        </div>
        <div style="margin-top: 10px;margin-bottom: 10px;">
            当前输入第 {{ pageRandom+numberIndex }} 页数字<el-input :disabled="timeOver" ref="inputField2" v-model="number" placeholder="请输入数字" @keyup.enter.native="numbermGet"></el-input>
        </div>
        <div style="margin-top: 10px;margin-bottom: 10px;">
            倒计时 {{ remainingSeconds }} 秒  ，输入数字 {{ sumInput }} ， 正确数字  {{ rightInput }}
        </div>
    </div>
</template>
<script>
export default {
    name:'testBank',
    data(){
        return {
            chuanpiao: [
                [
                    163916,
                    84761,
                    1137953,
                    1815031,
                    61562
                ],
                [
                    1506767,
                    74708,
                    817418,
                    91381,
                    1698189
                ],
                [
                    92549,
                    152750116,
                    156734,
                    834698,
                    25119738
                ],
                [
                    4517,
                    5170111,
                    6879,
                    9159,
                    882698,
                ],
                [
                    1926901,
                    874058,
                    4566,
                    49848,
                    18866484
                ],[
                    76081239,
                    56515,
                    182609154,
                    5743,
                    659978
                ],[
                    1149989,
                    148887,
                    890378,
                    1100193,
                    96931
                ],[
                    1077773,
                    72183,
                    1106093,
                    33958,
                    1641011
                ],[
                    272182,
                    136237844,
                    132540486,
                    95022,
                    5435005
                ],[
                    25148794,
                    863498,
                    9442,
                    2175501,
                    76434
                ],[
                    168006207,
                    5575457,
                    1924415,
                    8327,
                    123750
                ],[
                    127395078,
                    1099249,
                    99002758,
                    175807420,
                    129698405
                ],[
                    63440,
                    146801016,
                    59560,
                    1171465,
                    65852
                ],[
                    76714263,
                    6745,
                    182390820,
                    66257,
                    1128277
                ],[
                    19183928,
                    140621563,
                    132418675,
                    162586,
                    74698921
                ],[
                    93367,
                    78464,
                    23743,
                    1099957,
                    54388
                ],[
                    67880,
                    9934,
                    6379,
                    140907,
                    99001999
                ],[
                    48682,
                    1442131,
                    77181495,
                    1708133,
                    1708133,
                    94114
                ],[
                    158416465,
                    64239,
                    6941,
                    905738,
                    25545835
                ],[
                    185196,
                    1121669,
                    155138,
                    1166981,
                    34051
                ],[
                    25122462,
                    7473,
                    497147,
                    1182557,
                    82220
                ],[
                    123218,
                    145351062,
                    78043,
                    25012217,
                    643658
                ],[
                    64422,
                    1539085,
                    657098,
                    26377753,
                    140641
                ],[
                    12859887,
                    122826661,
                    1119073,
                    667658,
                    62392193
                ],[
                    174689,
                    80851,
                    175487,
                    137517639,
                    164595918
                ],[
                    1499309,
                    99015661,
                    1135357,
                    62393193,
                    185063
                ],[
                    67509,
                    147690,
                    163251,
                    1643497,
                    92043
                ],[
                    33115,
                    177083,
                    155803,
                    47578,
                    1685759
                ],[
                    628298,
                    4324,
                    132262,
                    707018,
                    25659810
                ],[
                    99003011,
                    73574,
                    19183718,
                    914378,
                    99035648
                ],[
                    62391693,
                    148488,
                    866378,
                    9991,
                    814538
                ],[
                    663818,
                    62393793,
                    57950,
                    88793,
                    6167771
                ],[
                    126594874,
                    19284801,
                    18986146,
                    98991626,
                    278007
                ],[
                    590858,
                    99036913,
                    1432187,
                    162187,
                    44113
                ],[
                    78511,
                    26584028,
                    81782,
                    151547,
                    87871
                ],[
                    172960,
                    1633039,
                    773258,
                    160444,
                    77302071
                ],
                [
                    99011866,
                    75960663,
                    1136353,
                    1143853,
                    93698
                ],[
                    75900375,
                    129395588,
                    147493307,
                    81439,
                    151148
                ],[
                    62915,
                    1179961,
                    1611179,
                    186393,
                    66577
                ],[
                    111189526,
                    59274,
                    99021227,
                    19178783,
                    1149517
                ],[
                    26024530,
                    19184978,
                    26138505,
                    119793140,
                    182441986
                ],[
                    172606604,
                    99122,
                    96763,
                    25104302,
                    9010
                ],[
                    77136279,
                    604298,
                    25112730,
                    182802,
                    42930547
                ],[
                    7345,
                    63135,
                    1141965,
                    7078,
                    745418
                ],[
                    19185083,
                    6673,
                    24561360,
                    19174478,
                    180009
                ],[
                    99017938,
                    74699521,
                    99027805,
                    25956145,
                    1203475
                ],[
                    6535,
                    297739,
                    3250,
                    9941,
                    172162
                ],[
                    60990,
                    98809,
                    49495,
                    68998,
                    1087921
                ],[
                    2981,
                    75147,
                    77721,
                    49550,
                    129336
                ],[
                    782750,
                    1330261,
                    66281,
                    7880641,
                    74432
                ],[
                    1695703,
                    57685,
                    69785,
                    138595856,
                    154201912
                ],[
                    1362579,
                    639818,
                    75674295,
                    57217,
                    1163699
                ],[
                    679178,
                    4190,
                    159261,
                    80152,
                    1225849
                ],[
                    183134277,
                    51992,
                    631178,
                    1128895,
                    9190
                ],[
                    1205961,
                    2051201,
                    1148783,
                    88573,
                    19944712
                ],[
                    76126455,
                    1479421,
                    19177313,
                    644618,
                    77226711
                ],[
                    1740451,
                    130595894,
                    724298,
                    5379,
                    186260
                ],[
                    655178,
                    187058,
                    98426,
                    658058,
                    76955415
                ],[
                    25762288,
                    19174058,
                    24723148,
                    99048045,
                    171098
                ],[
                    80789,
                    19174583,
                    98996180,
                    77362359,
                    3787
                ],[
                    6579,
                    544914,
                    841418,
                    163594233,
                    171806458
                ],[
                    1119545,
                    1387438,
                    24566808,
                    153401708,
                    177007726
                ],[
                    6475,
                    9965,
                    58928,
                    20055703,
                    162719
                ],[
                    2013911,
                    107057466,
                    188078339,
                    70285,
                    1178073
                ],[
                    99325,
                    74697121,
                    1092877,
                    133108694,
                    153621594
                ],[
                    593738,
                    62393693,
                    6919671,
                    7669,
                    163714
                ],[
                    184398,
                    584138,
                    74003,
                    59890597,
                    5979
                ],[
                    2847,
                    76895127,
                    5466,
                    53253,
                    2098435
                ],[
                    1153755,
                    875978,
                    99041467,
                    76970487,
                    1916957
                ],[
                    94427,
                    85037,
                    1859779,
                    176418,
                    99020468
                ],[
                    74698521,
                    136385,
                    102954886,
                    57451,
                    1161789
                ],[
                    1469477,
                    99037419,
                    160192,
                    1147629,
                    50006
                ],[
                    7337,
                    1123793,
                    1678301,
                    1146921,
                    5066
                ],[
                    77558295,
                    76322391,
                    31688,
                    170606094,
                    148499434
                ],[
                    128270294,
                    187191,
                    180608644,
                    99026034,
                    1147865
                ],[
                    62392293,
                    7444,
                    99009336,
                    7622125,
                    58745
                ],[
                    65738,
                    36577432,
                    99034889,
                    67045,
                    1108689
                ],[
                    169390789,
                    178679,
                    146227,
                    135397118,
                    137211274
                ],[
                    1165093,
                    1172881,
                    76759479,
                    136252,
                    62393093
                ],[
                    580298,
                    175242406,
                    63769,
                    136141,
                    25106118
                ],[
                    1670843,
                    1123085,
                    1143617,
                    174157,
                    13863347
                ],[
                    1603721,
                    99034130,
                    6607,
                    8945,
                    664461
                ],[
                    193365144,
                    44048,
                    9345,
                    99045768,
                    2744
                ],[
                    55985,
                    75433,
                    52124,
                    843338,
                    99039190
                ],[
                    166177,
                    181206,
                    159159922,
                    188054525,
                    115954917
                ],[
                    9044,
                    1175477,
                    2105893,
                    19174373,
                    4403
                ],[
                    4459,
                    135853,
                    1169341,
                    97244,
                    19178573
                ],[
                    1167925,
                    5470805,
                    1989051,
                    2153127,
                    63468
                ],[
                    77286999,
                    82957,
                    91050,
                    72830,
                    1372523
                ],[
                    2073575,
                    4979,
                    24574980,
                    1680787,
                    86085
                ],[
                    1121905,
                    19228804,
                    9922,
                    1228335,
                    6166
                ],[
                    85033,
                    796298,
                    69999,
                    99028311,
                    1078717
                ],[
                    147823,
                    5079,
                    139402,
                    24816224,
                    355565
                ],[
                    146493,
                    1100429,
                    748298,
                    24993551,
                    8345
                ],[
                    804938,
                    59889397,
                    95593,
                    1109007,
                    55413
                ],[
                    66887,
                    1243251,
                    55842,
                    77196567,
                    9951
                ],[
                    1191045,
                    1240765,
                    5405052,
                    1146449,
                    54971,
                ],[
                    90057,
                    82255,
                    24797558,
                    86416,
                    1409813
                ],[
                    749258,
                    75734583,
                    188068133,
                    6844,
                    869258
                ],[
                    81085,
                    233066,
                    2170529,
                    161921,
                    75538647
                ]
                
            ],
            problem: '', //题号
            problemIndex: 1, //题号计数
            pageRandom: 0,
            rowRandom:0,

            showInputNumber: false,
            number: '',
            numberIndex: 0,

            sumInput:0,
            rightInput:0,

            timeOver:false,
            remainingSeconds: 300, // 5分钟 * 60秒
        }
    },
    methods:{
        problemGet(){ //获取题号
            if(Number(this.problem)===this.problemIndex){
                this.showInputNumber = true
                this.pageRandom=Math.floor(Math.random() * 13)+1 //随机页码 1 - 80
                this.rowRandom=Math.floor(Math.random() * 5)+1 //随机行数 1 - 5
                this.number = ''
                this.$refs.inputField2.focus();
            }
            if(Number(this.problem)===1){// 第一次开始倒计时
                this.countDown()
            }
        },
        numbermGet(){ //获取数字
            

            this.sumInput++
            this.checkNumber(Number(this.number))

            this.numberIndex++
            

            if(this.numberIndex===19){//已经输入足够，跳回到选择题号
                this.showInputNumber = false
                this.numberIndex = 0

                this.problemIndex++
                this.problem = ''
                this.$refs.inputField.focus();
            }else{//输入不够，继续输入
                this.number
                this.number=''
                this.$refs.inputField2.focus();
            }

           
        },
        checkNumber(number){ // 判断输入的数字是否正确
            //console.log(number)
            //console.log(this.chuanpiao[this.pageRandom-1+this.numberIndex][this.rowRandom-1])
            if(number===this.chuanpiao[this.pageRandom-1+this.numberIndex][this.rowRandom-1]){
                this.rightInput++
            }
        },
        countDown() {
            if (this.remainingSeconds > 0) {
                this.remainingSeconds -= 1;
                setTimeout(this.countDown, 1000);
            }else{
                this.timeOver = true
                alert("时间到")
            }
        }
    },
    mounted(){
        this.$refs.inputField.focus();
    },
}
</script>
<style scoped>
.content {
    padding-left: 20px;
    padding-top: 20px;
}
</style>